#include <bits/stdc++.h>
using namespace std;
int T,p[1010000]={};
double begi[1010000]={},en[1010000]={};
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        int n,m,L,V,ans1=0,ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            int d,v,a;
            cin>>d>>v>>a;
            if(v>V){
                begi[i]=d;
                if(a>=0){
                    en[i]=L;
                }
                else{
                    en[i]=d+(V*V-v*v)/(2*a);
                }
            }
            else{
                if(a>0){
                    begi[i]=d+(V*V-v*v)/(2*a)+0.00000001;
                    en[i]=L;
                }
            }
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(begi[i]<=p[j]&&p[j]<=en[i]){
                    ans1++;
                    break;
                }
            }
        }
        cout<<ans1<<endl;
    }
    return 0;
}
